package cn.school.entity;

import java.util.ArrayList;
import java.util.List;

/**
 * @author oldliu
 * @since 1.0
 */
public class  Page<T> {
    private int pageNo=1;//当前页号
    private int pageSize=10;//默认值
    private int totalLines;//总行数
    private int totalPages;//总页数
    private List<T> data=new ArrayList<>(0);
    public Page(){}
    public Page(int pageNo, int pageSize, int totalLines, int totalPages, List<T> data) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        //this.totalLines = totalLines;
        this.setTotalLines(totalLines);
        this.totalPages = totalPages;
        this.data = data;
    }

    public Page(int pageNo, int pageSize, int totalLines, List<T> data) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
        //this.totalLines = totalLines;
        this.setTotalLines(totalLines);
        this.data = data;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        this.pageNo = pageNo;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public int getTotalLines() {
        return totalLines;
    }

    public void setTotalLines(int totalLines) {
        this.totalLines = totalLines;
        //计算总页数
        this.totalPages=(this.totalLines/this.pageSize)+(this.totalLines%this.pageSize==0?0:1);
    }

    public int getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(int totalPages) {
        this.totalPages = totalPages;
    }

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }
}
